package com.bckj.fastboot.core.extra.retry;

import com.bckj.fastboot.core.util.SpringUtils;

public class FastRetryTemplateBuilder {

    private int maxRetryCount = 3;
    private long initialInterval = 5000;
    private int multiplier = 2;
    private String className;
    private String methodName;
    private Object[] args;

    public FastRetryTemplateBuilder maxRetryCount(int maxRetryCount) {
        this.maxRetryCount = maxRetryCount;
        return this;
    }

    public FastRetryTemplateBuilder initialInterval(long initialInterval) {
        this.initialInterval = initialInterval;
        return this;
    }

    public FastRetryTemplateBuilder multiplier(int multiplier) {
        this.multiplier = multiplier;
        return this;
    }

    public FastRetryTemplateBuilder className(String className) {
        this.className = className;
        return this;
    }

    public FastRetryTemplateBuilder methodName(String methodName) {
        this.methodName = methodName;
        return this;
    }

    public FastRetryTemplateBuilder args(Object[] args) {
        this.args = args;
        return this;
    }

    public FastRetryTemplate build() {
        FastRetryTemplate fastRetryTemplate = SpringUtils.getBean(FastRetryTemplate.class);
        fastRetryTemplate.setMaxRetryCount(maxRetryCount);
        fastRetryTemplate.setInitialInterval(initialInterval);
        fastRetryTemplate.setMultiplier(multiplier);
        fastRetryTemplate.setClassName(className);
        fastRetryTemplate.setMethodName(methodName);
        fastRetryTemplate.setArgs(args);
        return fastRetryTemplate;
    }
}
